home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / sst115j.lzh / WTEST.C < prev   
C/C++ Source or Header  |  1992-07-18  |  3KB  |  104 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*                                  demo.c                                  */
  3. /*                       main demo of the SST toolkit                       */
  4. /* ------------------------------------------------------------------------ */
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <mem.h>
  8. #include <stdlib.h>
  9. #include <conio.h>
  10. #include <alloc.h>
  11.  
  12. #include "sstvid.h"
  13. #include "sstwin.h"
  14. #define MAXWINS    1024
  15.  
  16.  
  17. void wcolour(WINDOW *wnd,int a, int fg, int bg, int i);
  18. void wtitle(WINDOW *wnd, char *s, int j);
  19. void wborder(WINDOW *wnd);
  20. void wshow(WINDOW *wnd);
  21. void wwrite(WINDOW *wnd, unsigned int ram);
  22. void main(void);
  23.  
  24. /* ------------------------------------------------------------------------ */
  25. /* ------------------------------------------------------------------------ */
  26. void wcolour(WINDOW *wnd,int a, int fg, int bg, int i)
  27.  
  28. {
  29.     Wsetcolour(wnd, a, fg, bg, i);
  30. }
  31.  
  32. /* ------------------------------------------------------------------------ */
  33. /*    */
  34. /* ------------------------------------------------------------------------ */
  35. void wtitle(WINDOW *wnd, char *s, int j)
  36.  
  37. {
  38.   Wsettitle(wnd,s,j);
  39. }
  40.  
  41. /* ------------------------------------------------------------------------ */
  42. /*    */
  43. /* ------------------------------------------------------------------------ */
  44. void wborder(WINDOW *wnd)
  45.  
  46. {
  47.    Wsetborder(wnd,BRD_SINGLE);
  48. }
  49.  
  50. /* ------------------------------------------------------------------------ */
  51. /*    */
  52. /* ------------------------------------------------------------------------ */
  53. void wshow(WINDOW *wnd)
  54.  
  55. {
  56.     Wshow(wnd);
  57. }
  58.  
  59. /* ------------------------------------------------------------------------ */
  60. /*    */
  61. /* ------------------------------------------------------------------------ */
  62. void wwrite(WINDOW *wnd, unsigned int ram)
  63.  
  64. {
  65.   Wprintf(wnd,"Core  = %u bytes\n",ram);
  66. }
  67.  
  68. /* ------------------------------------------------------------------------ */
  69. void main(void)
  70. {
  71.     int ctr = 0, l;
  72.     unsigned int ram, wsize;
  73.     unsigned int maxused;
  74.     char s[13];
  75.     WINDOW **wnd;
  76.  
  77.     for (l = 0 ; l < MAXWINS ; l++) {
  78.       ram = (unsigned) coreleft();
  79.       sprintf(s,"[Win %3d]",l);
  80.       wnd[l] = Westablish(0, 0, 25, 80);
  81.       if (ram < 8192)
  82.         break;
  83.       wshow(wnd[l]);   /* show window first */
  84.       wcolour(wnd[l], WIN_ALL, CYAN, BLUE, BRIGHT);
  85.       wtitle(wnd[l],s,JUST_L);
  86.       wborder(wnd[l]);
  87.       wwrite(wnd[l],ram);
  88.       wsize = (unsigned)coreleft();
  89.       wsize = ram - wsize;
  90.       ctr++;
  91.       wsize = ram - (unsigned)coreleft();
  92.     }
  93.     Wdelete(wnd[l]);
  94.     while(l--) {
  95.     Wdelete(wnd[l]);
  96.     }
  97.   fprintf(stdout,"\nMaximum windows opened, limited by HEAP.\n");
  98.   fprintf(stdout,"Memory allocated by window    = %d\n",wsize);
  99.   fprintf(stdout,"Total Windows opened          = %d\n",ctr);
  100. }
  101.  
  102.  
  103.  
  104.